import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:getxsample/common/routes.dart';

import 'common/SharedPreferencesHelper.dart';
import 'common/messages.dart';

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await SharedPreferencesHelper.init();
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return GetMaterialApp(
      translations: Messages(),
      // 你的翻译
      locale: const Locale('zh', 'CN'),
      // 将会按照此处指定的语言翻译
      fallbackLocale: const Locale('en', 'US'),
      // 添加一个回调语言选项，以备上面指定的语言翻译不存在

      title: 'Flutter Demo',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
        textButtonTheme: TextButtonThemeData(
          style: TextButton.styleFrom(
            foregroundColor: Colors.white,
            backgroundColor: Colors.purple,
            shape: RoundedRectangleBorder(
              borderRadius: BorderRadius.circular(20), // 全局圆角按钮
            ),
          ),
        ),
        elevatedButtonTheme: ElevatedButtonThemeData(style: ElevatedButton.styleFrom(foregroundColor: Colors.white, backgroundColor: Colors.red)),
        outlinedButtonTheme: OutlinedButtonThemeData(
          style: OutlinedButton.styleFrom(
            foregroundColor: Colors.purple, // 字体颜色
            side: const BorderSide(color: Colors.purple), // 边框颜色
            shape: RoundedRectangleBorder(
              borderRadius: BorderRadius.circular(20), // 全局圆角按钮
            ),
          ),
        ),
      ),
      unknownRoute: Routes.unkonwn_page,
      initialRoute: Routes.HOME,
      getPages: Routes.routes,
    );
  }
}
